#ifndef USART_H
#define USART_H

#include "stm32f10x.h"

//#define USART1_TX_SIZE	256
//#define USART1_RX_SIZE	256

//#define USART2_TX_SIZE	256
//#define USART2_RX_SIZE	256

//#define UART3_TX_SIZE	256
//#define UART3_RX_SIZE	256

//#define COMn                             3U

//#define EVAL_COM1                        USART1
//#define EVAL_COM1_CLK                    RCU_USART1
//#define EVAL_COM1_TX_PIN                 GPIO_PIN_2
//#define EVAL_COM1_RX_PIN                 GPIO_PIN_3
//#define EVAL_COM1_GPIO_PORT              GPIOA
//#define EVAL_COM1_GPIO_CLK               RCU_GPIOA
//#define EVAL_COM1_IRQ                    USART1_IRQn

//#define EVAL_COM2                        USART2
//#define EVAL_COM2_CLK                    RCU_USART2
//#define EVAL_COM2_TX_PIN                 GPIO_PIN_10
//#define EVAL_COM2_RX_PIN                 GPIO_PIN_11
//#define EVAL_COM2_GPIO_PORT              GPIOB
//#define EVAL_COM2_GPIO_CLK               RCU_GPIOB
//#define EVAL_COM2_IRQ                    USART2_IRQn

//#define EVAL_COM3                        UART3
//#define EVAL_COM3_CLK                    RCU_UART3
//#define EVAL_COM3_TX_PIN                 GPIO_PIN_10
//#define EVAL_COM3_RX_PIN                 GPIO_PIN_11
//#define EVAL_COM3_GPIO_PORT              GPIOC
//#define EVAL_COM3_GPIO_CLK               RCU_GPIOC
//#define EVAL_COM3_IRQ                    UART3_IRQn


//#define USART1                   USART1
#define USART1_GPIO              GPIOA
#define USART1_CLK               RCC_APB2Periph_USART1
#define USART1_GPIO_CLK          RCC_APB2Periph_GPIOA
#define USART1_RxPin             GPIO_Pin_10
#define USART1_TxPin             GPIO_Pin_9
#define USART1_Tx_DMA_Channel    DMA1_Channel4
#define USART1_Tx_DMA_FLAG       DMA1_FLAG_TC4
#define USART1_Rx_DMA_Channel    DMA1_Channel5
#define USART1_Rx_DMA_FLAG       DMA1_FLAG_TC5
#define USART1_DR_Base           0x40013804

////#define USART2                   USART2
//#define USART2_GPIO              GPIOA//D
//#define USART2_CLK               RCC_APB1Periph_USART2
//#define USART2_GPIO_CLK          RCC_APB2Periph_GPIOA//RCC_APB2Periph_GPIOD
//#define USART2_RxPin             GPIO_Pin_3//6
//#define USART2_TxPin             GPIO_Pin_2//5
//#define USART2_Tx_DMA_Channel    DMA1_Channel7
//#define USART2_Tx_DMA_FLAG       DMA1_FLAG_TC7
//#define USART2_Rx_DMA_Channel    DMA1_Channel6
//#define USART2_Rx_DMA_FLAG       DMA1_FLAG_TC6
//#define USART2_DR_Base           0x40004404

//#define SP485_Master_RDEN_PIN       GPIO_Pin_4
//#define SP485_Master_RDEN_PORT      GPIOA

#define SP485_Slave_RDEN_PIN        GPIO_Pin_11//7//12
#define SP485_Slave_RDEN_PORT       GPIOA

//#define SP485_Master_RXEN           GPIO_ResetBits(SP485_Master_RDEN_PORT, SP485_Master_RDEN_PIN);
//#define SP485_Master_TXEN           GPIO_SetBits(SP485_Master_RDEN_PORT, SP485_Master_RDEN_PIN);

#define SP485_Slave_RXEN            GPIO_ResetBits(SP485_Slave_RDEN_PORT, SP485_Slave_RDEN_PIN);
#define SP485_Slave_TXEN            GPIO_SetBits(SP485_Slave_RDEN_PORT, SP485_Slave_RDEN_PIN);

//typedef struct
//{
//    unsigned char buffer[USART0_RX_SIZE];
//    unsigned char nbRxCounter;
//} UART_TC_RxVariate_T;
//typedef struct
//{
//    unsigned char buffer[USART1_RX_SIZE];
//    unsigned char nbRxCounter;
//} UART_ESP_RxVariate_T;
//typedef struct
//{
//    unsigned char buffer[USART2_RX_SIZE];
//    unsigned char nbRxCounter;
//} UART_LCD_RxVariate_T;

//typedef struct
//{
//    unsigned char buffer[UART3_RX_SIZE];
//    unsigned char nbRxCounter;
//} UART_ADP_RxVariate_T;

//typedef struct
//{
//    unsigned char buffer[UART4_RX_SIZE];
//    unsigned char nbRxCounter;
//} UART_VOI_RxVariate_T;





void MyUSART_Init(void);
void USART1_SEND(uint8_t *Buffer, uint32_t Length);
//void USART2_SEND(uint8_t *Buffer, uint32_t Length);
//void TC_Send_Byte(uint8_t *data,int leng);
//void ESP_Send_Byte(uint8_t *data,int leng);
//void LCD_Send_Byte(uint8_t *data,int leng);
//void ADP_Send_Byte(uint8_t *data,int leng);
//void VOICE_Send_Byte(uint8_t *data,int leng);




#endif
